﻿@model TCM.Instructor

@{
    
    ViewBag.Title = "Edit";
}

<h2>Edit Instructor <span class="FormTitle">@Html.DisplayFor(model => model.Name)</span></h2>

@using (Html.BeginForm())
{
    @*<a href="~/Views/Instructor/Edit.cshtml">~/Views/Instructor/Edit.cshtml</a>*@
    
    @Html.ValidationSummary(true)
    //13-72013 enas 
      <table style="width: 99.9%">
        <tr>
            <td class="IndexBack">
                @Html.ActionLink(" ", "Index")</td>
            <td style="text-align: right">
                </td>
        </tr>
    </table>
     <div class="toolbar">
        <input type="submit" value="Save" class="submit" />        
    </div> 
     <div class="HiddenFor">
        @Html.HiddenFor(x => x.InstructorID )
    </div>
    <div class="NavSubMenu">
        <span class="SubMenu_Title">Instructor ...</span><br />
        
        <div class="SubMneu">
            <a href="#" id="Information" onclick="changeMenu(this.id)">
                <span class="NavSubMenu_Title">Information</span>
                <span class="NavSubMenu_Body">General Information Instructor</span>
            </a>
        </div>
        <div class="SubMneu">
            <a href="#" id="InstructorLevel" onclick="changeMenu(this.id)">
                <span class="NavSubMenu_Title">Levels</span>
                <span class="NavSubMenu_Body">Instructor Levels</span>
            </a>
        </div>
    </div>
    
    <div class="ContentSubMenu">
    <div id="tabInformation" class="SubMenuContent active">
        <fieldset>
            <legend>Instructor</legend>
          
          
            <ol>

                @Html.HiddenFor(model => model.InstructorID)

                <li class="editor-label">
                    @Html.LabelFor(model => model.Name)

                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </li>

                

               

                <li class="editor-label">
                    @Html.LabelFor(model => model.Email1)
                    @Html.EditorFor(model => model.Email1)
                    @Html.ValidationMessageFor(model => model.Email1)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.Email2)

                    @Html.EditorFor(model => model.Email2)
                    @Html.ValidationMessageFor(model => model.Email2)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.Mobile1)

                    @Html.EditorFor(model => model.Mobile1)
                    @Html.ValidationMessageFor(model => model.Mobile1)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.Mobile2)

                    @Html.EditorFor(model => model.Mobile2)
                    @Html.ValidationMessageFor(model => model.Mobile2)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.Address)

                    @Html.EditorFor(model => model.Address)
                    @Html.ValidationMessageFor(model => model.Address)
                </li>

               

                <li class="editor-label">
                    @Html.LabelFor(model => model.Phone)

                    @Html.EditorFor(model => model.Phone)
                    @Html.ValidationMessageFor(model => model.Phone)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.Education)

                    @Html.EditorFor(model => model.Education)
                    @Html.ValidationMessageFor(model => model.Education)
                </li>

                <li class="editor-label OneColumn">
                    @Html.LabelFor(model => model.OtherDetails)

                    @Html.TextAreaFor(model => model.OtherDetails)
                    @Html.ValidationMessageFor(model => model.OtherDetails)
                </li>

               

                <li class="editor-label">
                    @Html.LabelFor(model => model.Salary)

                    @Html.EditorFor(model => model.Salary)
                    @Html.ValidationMessageFor(model => model.Salary)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.WorkingHours)

                    @Html.EditorFor(model => model.WorkingHours)
                    @Html.ValidationMessageFor(model => model.WorkingHours)
                </li>

                <li class="editor-label">
                    @Html.LabelFor(model => model.Experience)

                    @Html.EditorFor(model => model.Experience)
                    @Html.ValidationMessageFor(model => model.Experience)
                </li>

               

               
            </ol>
        </fieldset>
    </div> 
    <div id="tabInstructorLevel" class ="SubMenuContent">
        <span class="SubMenu_Title">Levels</span>

            <div class="toolbar">
                <input id="addAnother" type="button" value="New Level" />
            </div>
            <br />
        <table id="grdLevels" class="grdTable" style="width: 100%;" cellspacing="0">
                <thead>
                    <tr class="GridHeader">
                        <th>Subject Name</th>
                        <th>Level Name</th>   
                        <th>Delete</th>                   
                    </tr>
                </thead>
                <tbody id="items">
        @if (Model != null)
        {
            if (Model.InstructorSubjects != null)
            {
                foreach (var item in Model.InstructorSubjects)
                {
                  <tr>
                    @Html.Partial("_RelatedInstructorSubjectLevels", item)
                   </tr> 
                }
            }
        }
        </tbody>
        </table>    
    </div> 
 </div>     
}

@*<div>
    @Html.ActionLink("Back to List", "Index")
</div>*@

@*@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}*@
<script lang="javascript" type="text/javascript">
    $(function () {
       

        $("#addAnother").click(function () {
            alert('s');
            debugger;
            //$.get('/Course/EditRelatedCourseSchedule', function (template) {            
            $.get('/Instructor/InstructorSubjectsRow/?instructorID=@Model.InstructorID', function (template) {
                ///remove tr which is came by partial view because 
                ///this tr tag come after input which makes a problem whith flexigrid 
                /// so after deleting this tr tag , i enter it again to include input that 
                /// is come first                
                //var temp1 = template.toString().replace("<tr>", "");

                //temp1 = temp1.toString().replace("</tr>", "");

                //var rhtml = "<tr>" + temp1 + "</tr>";

                /////append to flexigrid               
                //$("#grdLevels tbody tr:first").before(rhtml);
                debugger;
                $("#items").append(template);

                ///recall the timepicker function after adding the new html tags.
                //$('.timepicker input').timepicker();
            });
        });        
    });

    $(document).ajaxStart(function () {
        //debugger;
        $("#spinner").show();//text("Triggered ajaxStart handler.");
    });
    $(document).ajaxComplete(function () {
       // debugger;
        $("#spinner").hide(100);//text("Triggered ajaxStart handler.");
    });
</script>

@*<script type ="text/javascript" >

    function changeMenu(item) {
        $(".SubMneu a").removeClass("SubMenuActive");
        if (item) {
            $(".SubMneu a#" + item + "").addClass("SubMenuActive");
            $(".SubMenuContent").removeClass("active").hide();
            $(".SubMenuContent#tab" + item + "").fadeIn(500);
        }
    }
</script>*@
